<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="./css/mui.min.css" rel="stylesheet" />
		<link href="./css/setting.css" rel="stylesheet">
		<link href="./css/form2.css" rel="stylesheet">		
		<style>
			.area {
				margin: 20px auto 0px auto;
			}
			.mui-input-group:first-child {
				margin-top: 20px;
			}
			.mui-input-group label {
				width: 22%;
			}
			.mui-input-row label~input,
			.mui-input-row label~select,
			.mui-input-row label~textarea {
				width: 78%;
			}
			.mui-checkbox input[type=checkbox],
			.mui-radio input[type=radio] {
				top: 6px;
			}
			.mui-content-padded {
				margin-top: 25px;
			}
			.mui-btn {
				padding: 10px;
			}
			.mui-input-row label~input, .mui-input-row label~select, .mui-input-row label~textarea{
				margin-top: 1px;
			}
			.bgcolor {
    				background-color: rgb(255, 91, 55) !important;
			}
		</style>
	</head>

	<body>
		<script src="./js/mui.js"></script>
		<script src="./js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript" src="./js/vue.min.js"></script>
		<script type="text/javascript" src="./js/common.js"></script>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">找回密码</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<label style="font-size: 16px;">手机号</label>
					<input id='mobile' type="email" class="mui-input-clear mui-input" placeholder="请输入注册手机号">
				</div>
				<div style="position: relative;">
					<div class="mui-input-row">
						<input id='code' type="email" placeholder="请输入验证码" style="width: 60%;">
						<button type="button"  id="btn_send_yanzheng" style="border: 0;" style="" onclick="getCode('getCode');">获取验证码</button>
					</div>
				</div>
			</form>
			<div class="mui-button-row">
				<button  class="mui-btn mui-btn-warning bgcolor mui-pull-center" style="width: 100%;" onclick="subAction();">提交</button>
			</div>
		</div>
		<script>
			/*按钮倒计时60秒*/
			var wait=120;
			function getCode(sender) {
			  if(sender=="getCode"){
			  	var mobile = $("#mobile").val();
			  	if(isNull(mobile)||(!(/^1[34578]\d{9}$/.test(mobile)))){
			  		mui.toast("请输入正确手机号");
			  		return;
			  	}
			  	var result=ajaxAction(root+"index/getSMSCode",{mobile:mobile});
			  	if(result.status == "failed"){
			  		mui.toast(result.msg);
			  		return;
			  	}
			  }
			  if (wait == 0) {
			   $("#btn_send_yanzheng").attr("disabled",false);  
			   $("#btn_send_yanzheng").html("获取验证码");
			   wait = 120;
			  } else { 
				   $("#btn_send_yanzheng").attr("disabled",true);
				   $("#btn_send_yanzheng").html("重新发送(" + wait + "s)");
				   wait--;
				   setTimeout(function() {
				    getCode("");
			  		},1000)
			 	}
			}
			
			function subAction(){
				var phone = $("#mobile").val();
				var code = $("#code").val();
				if(isNull(phone)){
					mui.toast('请输入手机号');
					return;
				}
				if(!(/^1[34578]\d{9}$/.test(phone))) {
					mui.toast('手机号填写有误');
					return;
				}
				if(isNull(code)){
					mui.toast('请输入短信验证码');
					return;
				}
				var checkCodeResult = ajaxAction(root+"index/checkSMSCode",{mobile:phone,code:code});
				if(checkCodeResult.status == "failed"){
					mui.toast(checkCodeResult.msg);
					return;
				}
				mui.openWindow('resetPassword.html?mobile='+$("#mobile").val(), '', {});
			}
			
		</script>
	</body>

</html>